<?php


namespace App\Http\Requests;


class LoginRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => ['required', 'string', 'between:2,50', 'regex:/[a-zA-Z0-9_\x00-\xff]{2,50}/'],
            'password' => ['required', 'string', 'between:6,20'],
            'captcha' => ['required', 'captcha']
        ];
    }


    public function messages()
    {
        return [
            'username.required' => '请输入用户名',
            'username.string' => '用户名格式错误',
            'username.between' => '用户名字符长度2-50',
            'username.regex' => '用户名格式错误',
            'password.required' => '请输入密码',
            'password.string' => '密码格式错误',
            'password.between' => '密码字符长度6-20',
            'password.regex' => '密码格式错误',
            'captcha.required' => '请输入验证码',
            'captcha.captcha' => '验证码错误'
        ];
    }
}
